package cn.kgc.mybatis04.mapper;

import cn.kgc.mybatis04.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author: mosin
 * @version: v1.0  2022/11/24
 * 注解开发  使用注解完成sql语句的编写  一般使用在sql语句比较简单的情境下
 */
public interface UserMapper {

    @Select("select  *  from  user")
    List<User> selectList();

    @Insert("insert into user (username,password) values(#{username},#{password})")
    Integer addUser(User user);

    @Update("update user set username = #{username},password=#{password} where user_id =#{userId}")
    Integer updateUser(User user);

    @Delete("delete from user where user_id = #{id}")
    Integer deleteById(Integer id);

}
